using System;
using System.Collections.Generic;
using System.Text;
using MindFactorial.LaunchPoint.Common;

namespace MindFactorial.LaunchPoint.Runtime
{
    /// <summary>
    /// Represents Business Rules Engine context in LaunchPoint Server
    /// </summary>
    public class LaunchPointRuntimeContext : ContextObject 
    {
        BREContext _context = null;
        LaunchPointApplication _runnable = null;

        /// <summary>
        /// Creates a new context
        /// </summary>
        /// <param name="runnable"></param>
        internal LaunchPointRuntimeContext(LaunchPointApplication runnable)
        {
            _runnable = runnable;
            _context = new BREContext(_runnable);
        }

        /// <summary>
        /// Gets Business Rules Engine Context
        /// </summary>
        public BREContext RulesEngine
        {
            get
            {
                return _context;
            }
        }

        /// <summary>
        /// Registers a request handler to process incomming Messages.  The Messages to be
        /// processed will first be filtered by the filter parameter. If that returns true,
        /// request_handler will be called.
        /// </summary>
        /// <param name="filter">delegate used to evaluate incomming data for relevance</param>
        /// <param name="request_handler">delegate used to handle incomming connection</param>
        public void RegisterIncommingRequestHandler(IncommingMessageFiltrationHandler filter, IncommingMessageRequestHandler request_handler)
        {
            _runnable.RegisterIncommingRequestHandler(filter, request_handler);
        }

        /// <summary>
        /// Displays an alert Message
        /// </summary>
        /// <param name="Message">Message to be prompted</param>
        /// <param name="args">Arguments</param>
        public void Alert(string Message, params string[] args)
        {
            PromptManager.Alert(Message, args);
        }


    }
}
